<!doctype html>
<html  class="x-admin-sm">
	<head>
		<meta charset="UTF-8">
		<title>管理登录</title>
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="stylesheet" href="./css/font.css">
		<link rel="stylesheet" href="./css/login.css">
		<link rel="stylesheet" href="./css/index.css">
		<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script src="./lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="js/jquery.js"></script>
		<style type="text/css">
			span {
				display: inline-block;
				border: 1px solid red;
				line-height: 30px;
				visibility: hidden;
				height: 30px;
				background-color: #ffebeb;
				text-align: center;
				margin-top: 10px;
				color: red;
				width: 338px;
			}
		</style>
	</head>

	<body class="login-bg">

		<div  class="login layui-anim layui-anim-up" style="margin-top: 150px;">

			<form id="data_" method="post" class="layui-form" style="margin-top: 30px;">
				<input id="username" name="account" placeholder="账号" type="text" lay-verify="required" class="layui-input" oninput="value=value.replace(/\D+/,'')" maxlength="20">
				<span id="usernamez">22</span>
				<input id="password" name="pawd" lay-verify="required" placeholder="密码" type="password" class="layui-input" style="margin-top: 10px;"maxlength="20">
				<span id="passwordz">22</span>
				<input value="登录" id="login_" style="width:100%;margin-top: 10px;" type="button">
			</form>

		</div>

		<script>
			$("#username").focus(function() {
				$("#usernamez").css("visibility", "hidden");
			});

			$("#password").focus(function() {
				$("#passwordz").css("visibility", "hidden");
			});
			$("#login_").click(function() {
				if($("#username").val() == "") {
					$("#usernamez").css("visibility", "visible");
					$("#usernamez").empty();
					$("#usernamez").append("账号为空");
				} else if($("#password").val() == "") {
					$("#passwordz").css("visibility", "visible");
					$("#passwordz").empty();
					$("#passwordz").append("密码为空");
				} else {
					x();
				}
			});

			function x() {
				$.ajax({
					url: 'http://localhost:16111/user/g_administrator_login',
					type: 'post',
					dataType: 'json',
					xhrFields:{withCredentials: true},
					data: $("#data_").serialize(),
					success: function(data) {
						if(data.code == 1) {
                           location = "index.html"
                          // sessionStorage.setItem("adminuserid",data.data);
						} else {
							$("#usernamez").css("visibility", "visible");
							$("#usernamez").empty();
							$("#usernamez").append("账号或密码错误");
						}

					}
				});
			};
		</script>
		<!-- 底部结束 -->

	</body>
</html>